package com.webside.spread.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.webside.base.baseservice.impl.AbstractService;
import com.webside.spread.mapper.GenerateLinksMapper;
import com.webside.spread.mapper.SpreadMapper;
import com.webside.spread.model.GenerateLinksEntity;
import com.webside.spread.model.SpreadSupporterEntity;
import com.webside.spread.service.GenerateLinksService;
@Service("GerateLinksService")
public class GenerateLinksServiceImpl extends AbstractService<GenerateLinksEntity, Long> implements GenerateLinksService {
	@Autowired
	private GenerateLinksMapper generateLinksMapper;
	@Autowired
	private SpreadMapper spreadMapper;
	//这句必须要加上。不然会报空指针异常，因为在实际调用的时候不是BaseMapper调用，而是具体的mapper，这里为userMapper
		@Autowired
		public void setBaseMapper() {
			super.setBaseMapper(generateLinksMapper);
		}
	@Override
	public List<GenerateLinksEntity> queryAllLinks(Map<String,Object> parameter) {
		return generateLinksMapper.selectAllLinks(parameter);
	}

	@Override
	public List<GenerateLinksEntity> queryLinks(GenerateLinksEntity link) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String addLinks(GenerateLinksEntity link) {
		List<GenerateLinksEntity> links= generateLinksMapper.selectLinks(link);
		if(!links.isEmpty()){
			return "存在";
		}
		generateLinksMapper.addLinks(link);
		spreadMapper.addLinks(link.getSsCode());
		return "";
	}

	@Override
	public int updateLinks(GenerateLinksEntity link) {
		generateLinksMapper.updateLinks(link);
		int i =0;
		if(!generateLinksMapper.selectLinks(link).isEmpty()){
			i=1;
		}
		return i;
	}

	@Override
	public List<GenerateLinksEntity> queryListByPage(Map<String, Object> param) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public int deleteLinks(List<String> Ids) {
		// TODO Auto-generated method stub
		return 0;
	}

	

}
